#include "StdAfx.h"
#include "DWeapon.h"
#include "DBulletFirebolt.h"
#include "../DActorFactory.h"
#include "../../Game/DGame.h"
#include "../../Game/DWorld.h"

using namespace Weapons;

DWeapon::DWeapon(boost::shared_ptr<DIActor> source)
: m_source(source)
, m_eType(eNoWeapon)
, m_nLevel(1)
, m_fFireDelay(0.25f)
{
    
}

DWeapon::~DWeapon(void)
{
}

void DWeapon::fire(boost::shared_ptr<DGame> game, const vec2& origin, const vec2& dir, float dt)
{
    Weapons::BulletCreationParams params;
    params.startX = origin.x;
    params.startY = origin.y;

    switch(m_eType)
    {
        case eFirebolt: game->world()->addActor(DActorFactory::instance().createBullet(game, m_source.lock(), "Firebolt", params)); break;
    }
}

void DWeapon::setType(Type weaponType)
{
    m_eType = weaponType;
}

void DWeapon::setLevel(unsigned int weaponLevel)
{
    m_nLevel = weaponLevel;
}